// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import store from './store'
import App from './App'
import router from './router'

import YDUI from 'vue-ydui'
import 'vue-ydui/dist/ydui.rem.css'

// 参考 https://github.com/marcuswestin/store.js/
import storejs from 'store'
// stroe有效期插件 使用方法 store.set('key','value',new Date().getTime() + millisecond)
import expirePlugin from 'store/plugins/expire'
import API from './common/apiurl'
import STORECONST from './common/storeConst'
import HDUtils from 'hd/HDUtils'
import HDUI from './components/hdui'

// swiper
import 'swiper/dist/css/swiper.css'
import VueAwesomeSwiper from 'vue-awesome-swiper'

// 高德地图
import VueAMap from 'vue-amap'
import '../static/hd.styl'
import VueScrollTo from 'vue-scrollto';
storejs.addPlugin(expirePlugin)

// 注册全局方法
Vue.prototype.store = storejs
Vue.prototype.STORECONST = STORECONST
Vue.prototype.API = API

// 生产提示
Vue.config.productionTip = false

Vue.use(YDUI)
Vue.use(HDUI)
Vue.use(HDUtils)
Vue.use(VueAwesomeSwiper)
// 高德地图设置
Vue.use(VueAMap)
VueAMap.initAMapApiLoader({
  key: 'd4078a7d3d71b53c8ac91350076d8164',
  plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'Geolocation', 'AMap.LngLat']
})
Vue.use(VueScrollTo)
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App },
  methods: {
    // TODO
  },
  created () {
    // TODO
  },
  mounted () {
    // 监听网络变化
    window.addEventListener('offline', (e) => {
      this.$dialog.toast({mes: '网络连接失败,请检查后重试'})
    })
  }
})
